#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long double
#define uLL unsigned long long
using namespace std;
const int N=1.5e5+5;
const LL INF=1e18;
int n,m,A,B;
int vs[N];
queue<int>Q;
LL d[N],D[N];
vector<int>G[N],H[N];
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	freopen("edge.in","r",stdin);
	freopen("edge.out","w",stdout);
	cin>>n>>m>>A>>B,B=min(B,A+A);
	for(int i=1;i<=m;++i){
		int u,v;cin>>u>>v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}
	Q.emplace(1);
	fill(d+2,d+n+1,-1);
	while(!Q.empty()){
		const int u=Q.front();Q.pop();
		for(const auto&v:G[u])if(d[v]==-1)d[v]=d[u]+1,Q.emplace(v);
	}
	for(int i=1;i<=n;++i)d[i]=d[i]/2*B+d[i]%2*A;
	Q.emplace(1);
	fill(D+2,D+n+1,INF);
    for(int i=1;i<=n;++i)H[i]=G[i];
	while(!Q.empty()){
		const int u=Q.front();Q.pop();
		for(const auto&v:G[u])vs[v]=u;
		for(const auto&v:G[u]){
			int p=0;
			for(auto w:H[v])if(D[w]>D[u]+B)
                if(vs[w]==u)H[v][p++]=w;
				else D[w]=D[u]+B,Q.emplace(w);
            H[v].resize(p);
		}
	}
	for(int i=2;i<=n;++i)cout<<min(d[i],D[i])<<'\n';
	return 0;
}
/*
*/